var fs = require('fs');

var data = 'Everything is just beginning';

// 创建可读流
var writerStream = fs.createWriteStream('./output.txt');
// writerStream.setEncoding('UTF8');
// console.log(writerStream);
writerStream.write(data,"UTF8");
writerStream.end();


writerStream.on('finish', function (chunk) {
   console.log('文件写入完成');
});

// writerStream.on('end',function(chunk){
//     console.log(data);
// });

writerStream.on('error',function(err){
    console.log(err.stack);
});
console.log('执行完毕！');